package org.molamil.acto.types {
	import org.molamil.acto.core.parsers.ParserError;	
	
	import flexunit.framework.TestCase;	
	
	/**
	 * @author Jorge Hernandez
	 */
	public class BooleanTypeParserTest extends TestCase {
		
		
		// PROPERTIES
		
		private var instance:BooleanTypeParser;
		
		
		// CONSTRUCTOR
		
		public function BooleanTypeParserTest(methodName:String = null) {
			super(methodName);
		}
		
		
		// PUBLIC METHODS
		
		override public function setUp():void {
			instance = new BooleanTypeParser();
		}
		
		override public function tearDown():void {
			instance = null;
		}
		
		public function testParse():void {
			
			assertTrue("'true' parses to true", instance.parse("true"));
			assertTrue("'True' parses to true", instance.parse("True"));
			assertTrue("'TRUE' parses to true", instance.parse("TRUE"));
			
			assertFalse("'false' parses to false", instance.parse("false"));
			assertFalse("'FalsE' parses to false", instance.parse("FalsE"));
			assertFalse("'FALSE' parses to false", instance.parse("FALSE"));
			
			assertTrue("'1' parses to true", instance.parse("1"));
			
			assertFalse("'0' parses to false", instance.parse("0"));
			
			try {
				instance.parse("Jorge");
				fail("'Jorge' should fail");
			} catch (e:ParserError) {}
			
			try {
				instance.parse("yes");
				fail("'yes' should fail");
			} catch (e:ParserError) {}
			
			try {
				instance.parse("no");
				fail("'no' should fail");
			} catch (e:ParserError) {}
			
			try {
				instance.parse("  TRUE  ");
				fail("'  TRUE  ' should fail");
			} catch (e:ParserError) {}
			
			try {
				instance.parse("true  ");
				fail("'true  ' should fail");
			} catch (e:ParserError) {}
			
			try {
				instance.parse("");
				fail("'' (empty string) should fail");
			} catch (e:ParserError) {}
			
			try {
				instance.parse(null);
				fail("null should fail");
			} catch (e:ParserError) {}
			
			
		}
		
		
	}
	
}
